Imports Microsoft.VisualBasic

Public Class SignKidsConfigSection
    Inherits ConfigurationSection
    <ConfigurationProperty("defaultConnectionStringName", Defaultvalue:="LocalSQLServer")> Public Property DefaultConnectionStringname() As String
        Get
            Return Me("defaultConnectionStringName").ToString
        End Get
        Set(ByVal value As String)
            Me("defaultConnectionStringname") = value
        End Set
    End Property
    <ConfigurationProperty("contactForm", IsRequired:=True)> _
    Public ReadOnly Property ContactForm() As ContactFormElement
        Get
            Return CType(Me("contactForm"), ContactFormElement)
        End Get
    End Property
    <ConfigurationProperty("Article", isRequired:=True)> _
   Public ReadOnly Property Article() As ArticleElement
        Get
            Return CType(Me("Article"), ArticleElement)
        End Get
    End Property

    <ConfigurationProperty("Category", isRequired:=True)> _
    Public ReadOnly Property Category() As CategoryElement
        Get
            Return CType(Me("Category"), CategoryElement)
        End Get
    End Property

    <ConfigurationProperty("Comment", isRequired:=True)> _
    Public ReadOnly Property Comment() As CommentElement
        Get
            Return CType(Me("Comment"), CommentElement)
        End Get
    End Property

    <ConfigurationProperty("Amazon", isRequired:=True)> _
Public ReadOnly Property Amazon() As AmazonElement
        Get
            Return CType(Me("Amazon"), AmazonElement)
        End Get
    End Property


    Public Class ContactFormElement
        Inherits ConfigurationElement
        <ConfigurationProperty("mailSubject", DefaultValue:="Mail from SignKids.org: {0}")> Public Property MailSubject() As String
            Get
                Return CStr(Me("mailSubject"))
            End Get
            Set(ByVal value As String)
                Me("mailSubject") = value
            End Set
        End Property

        <ConfigurationProperty("MailTo", IsRequired:=True)> Public Property MailTo() As String
            Get
                Return CStr(Me("MailTo"))
            End Get
            Set(ByVal value As String)
                Me("MailTo") = value
            End Set
        End Property
    End Class

    Public Class ArticleElement
        Inherits ConfigurationElement
        <ConfigurationProperty("connectionStringName")> Public Property ConnectionStringName() As String
            Get
                Return CStr(Me("connectionStringName"))
            End Get
            Set(ByVal value As String)
                Me("connectionStringName") = value
            End Set
        End Property
        Public ReadOnly Property ConnectionString() As String

            Get
                Dim ConnectStringName As String
                If String.IsNullOrEmpty(Me.ConnectionStringName) Then
                    ConnectStringName = Globals.Settings.DefaultConnectionStringname
                Else
                    ConnectStringName = Me.ConnectionStringName
                End If
                Return ConfigurationManager.ConnectionStrings(ConnectStringName).ConnectionString
            End Get

        End Property
        <ConfigurationProperty("providerType", DefaultValue:="sk.DAL.SQLProviders.SQLArticleProvider")> _
        Public Property ProviderType() As String
            Get
                Return CStr(Me("providerType"))
            End Get
            Set(ByVal value As String)
                Me("providerType") = value
            End Set
        End Property
    End Class

    Public Class CategoryElement
        Inherits ConfigurationElement
        <ConfigurationProperty("connectionStringName")> Public Property ConnectionStringName() As String
            Get
                Return CStr(Me("connectionStringName"))
            End Get
            Set(ByVal value As String)
                Me("connectionStringName") = value
            End Set
        End Property
        Public ReadOnly Property ConnectionString() As String

            Get
                Dim ConnectStringName As String
                If String.IsNullOrEmpty(Me.ConnectionStringName) Then
                    ConnectStringName = Globals.Settings.DefaultConnectionStringname
                Else
                    ConnectStringName = Me.ConnectionStringName
                End If
                Return ConfigurationManager.ConnectionStrings(ConnectStringName).ConnectionString
            End Get

        End Property
        <ConfigurationProperty("providerType", DefaultValue:="sk.DAL.SQLProviders.SQLCategoryProvider")> _
        Public Property ProviderType() As String
            Get
                Return CStr(Me("providerType"))
            End Get
            Set(ByVal value As String)
                Me("providerType") = value
            End Set
        End Property
    End Class

    Public Class CommentElement
        Inherits ConfigurationElement
        <ConfigurationProperty("connectionStringName")> Public Property ConnectionStringName() As String
            Get
                Return CStr(Me("connectionStringName"))
            End Get
            Set(ByVal value As String)
                Me("connectionStringName") = value
            End Set
        End Property
        Public ReadOnly Property ConnectionString() As String

            Get
                Dim ConnectStringName As String
                If String.IsNullOrEmpty(Me.ConnectionStringName) Then
                    ConnectStringName = Globals.Settings.DefaultConnectionStringname
                Else
                    ConnectStringName = Me.ConnectionStringName
                End If
                Return ConfigurationManager.ConnectionStrings(ConnectStringName).ConnectionString
            End Get

        End Property
        <ConfigurationProperty("providerType", DefaultValue:="sk.DAL.SQLProviders.SQLCommentProvider")> _
        Public Property ProviderType() As String
            Get
                Return CStr(Me("providerType"))
            End Get
            Set(ByVal value As String)
                Me("providerType") = value
            End Set
        End Property
    End Class
    Public Class AmazonElement
        Inherits ConfigurationElement

        <ConfigurationProperty("accessKeyId", IsRequired:=True)> Public Property accessKeyId() As String
            Get
                Return CStr(Me("accessKeyId"))
            End Get
            Set(ByVal value As String)
                Me("accessKeyId") = value
            End Set
        End Property

        <ConfigurationProperty("associateTag", IsRequired:=True)> Public Property associateTag() As String
            Get
                Return CStr(Me("associateTag"))
            End Get
            Set(ByVal value As String)
                Me("associateTag") = value
            End Set
        End Property

        <ConfigurationProperty("connectionStringName")> Public Property ConnectionStringName() As String
            Get
                Return CStr(Me("connectionStringName"))
            End Get
            Set(ByVal value As String)
                Me("connectionStringName") = value
            End Set
        End Property
        Public ReadOnly Property ConnectionString() As String

            Get
                Dim ConnectStringName As String
                If String.IsNullOrEmpty(Me.ConnectionStringName) Then
                    ConnectStringName = Globals.Settings.DefaultConnectionStringname
                Else
                    ConnectStringName = Me.ConnectionStringName
                End If
                Return ConfigurationManager.ConnectionStrings(ConnectStringName).ConnectionString
            End Get

        End Property

        <ConfigurationProperty("providerType")> _
       Public Property ProviderType() As String
            Get
                Return CStr(Me("providerType"))
            End Get
            Set(ByVal value As String)
                Me("providerType") = value
            End Set
        End Property
    End Class

End Class
